var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    children_img_bg: app.myUlife.ulifeUrl + 'wx/children_img_bg.png',
    pendant_icon_img: app.myUlife.ulifeUrl + 'wx/pendant_icon_img.png',
    slide: app.myUlife.ulifeUrl + 'wx/slide_btn_icon.png',//默认图片


    //滑动
    scrollindex: 0,
    totalnum: 2,  //总共页面数
    starty: 0,  //开始的位置x
    endy: 0, //结束的位置y
    margintop: 0,  //滑动下拉距离


    list:[],//成长记录
  }, 

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    //根据用户ID查询好词好句
    var usid = wx.getStorageSync('usid');
    if (!usid) {
      wx.reLaunch({
        url: '../../pages/login/login'
      })
      return;
    }
    //查询我的阅读记录
    this.getMyAllReadLog();
  }, 


  getMyAllReadLog(){
    var that = this;
    var usid = wx.getStorageSync('usid');
    app.wxget({
      url: 'staticlog/getMyAllReadLog.html',
      data: {
        usid: usid
      },
      success: function (res) {
        that.setData({
          list: res.data,
          totalnum: res.data.length
        })
      }
    })
  },

  //滑动开始 start
  scrollTouchstart: function (e) {
    let py = e.touches[0].pageY;
    this.setData({
      starty: py
    })
  },
  scrollTouchmove: function (e) {
    let py = e.touches[0].pageY;
    let d = this.data;
    this.setData({
      endy: py,
    })
    if (py - d.starty < 100 && py - d.starty > -100) {
      this.setData({
        margintop: py - d.starty
      })
    }
  },
  scrollTouchend: function (e) {
    let d = this.data;
    if (d.endy - d.starty > 100 && d.scrollindex > 0) {
      this.setData({
        scrollindex: d.scrollindex - 1
      })
    } else if (d.endy - d.starty < -100 && d.scrollindex < this.data.totalnum - 1) {
      this.setData({
        scrollindex: d.scrollindex + 1
      })
    }
    this.setData({
      starty: 0,
      endy: 0,
      margintop: 0
    })
  },

  //向上翻页
  scrollTouchsyg: function () {
    let d = this.data;
    this.setData({
      scrollindex: d.scrollindex - 1
    })
    this.setData({
      starty: 0,
      endy: 0,
      margintop: 0
    })
  },
  //滑动开始 end




  //预览图片
  viewimage: function (e) {
    var picurl = e.target.dataset.picurl;
    wx.previewImage({
      current: picurl, // 当前显示图片的http链接
      urls: [picurl] // 需要预览的图片http链接列表
    })
  },
  

})